package com.liang.common.handler;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @name: JwtAuthenticationEntryPoint
 * @author: 李昂
 * @date: 2020-12-01 13:07
 * @description：JwtAuthenticationEntryPoint
 * @update: 2020-12-01 13:07
 */
@Component
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException {
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "凭证无效,请重新登录");
    }
}